package short_semester.questionnaire_planet.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import short_semester.questionnaire_planet.pojo.QuestionnaireRecord;
import short_semester.questionnaire_planet.pojo.SingleChoiceQuestion;
import short_semester.questionnaire_planet.pojo.SingleChoiceQuestionRecord;

import javax.transaction.Transactional;
import java.util.List;
import java.util.Optional;

public interface SingleChoiceQuestionRecordDao extends JpaRepository<SingleChoiceQuestionRecord,Integer> {
    List<SingleChoiceQuestionRecord> findAllByQuestionnaireRecord(QuestionnaireRecord questionnaireRecord);

    Optional<SingleChoiceQuestionRecord> findByQuestionnaireRecordAndSingleChoiceQuestion(
            QuestionnaireRecord questionnaireRecord, SingleChoiceQuestion singleChoiceQuestion);
    
    List<SingleChoiceQuestionRecord> findByQuestionnaireRecord(QuestionnaireRecord record);

    @Modifying
    @Transactional
    void deleteBySingleChoiceQuestion(SingleChoiceQuestion singleChoiceQuestion);

}
